package com.pic.mgt.initials;

import com.pic.mgt.log.IgxLog;
import com.pic.mgt.manager.terminal.TerminalManagementOperationException;
import com.pic.mgt.manager.terminal.TerminalManager;

public final class TerminalSynchronizeInitialBean implements InitialBean {
	private TerminalManager terminalManager;

	@Override
	public void initialize() throws InitialOperationException {
		try {
			terminalManager.synchronizeTerminals();
		} catch (TerminalManagementOperationException e) {
			try {
				throw new InitialOperationException(
						"SUDA-253 Initializing failed: synchronizing terminal failed." ,e);
			} catch (InitialOperationException e1) {
				// ********************** Log **********************
				IgxLog.messageLog.error(this, e1.getMessage());
				// ********************** Log **********************
				
				throw e1;
			}
		}
		
		// ********************** Log **********************
		if (IgxLog.messageLog.isDebugMode()) {
			IgxLog.messageLog.debug(this,
					"Initializing terminal synchronization completed.");
		}
		// ********************** Log **********************
	}
	
	// --- getter and setter ---

	public void setTerminalManager(TerminalManager terminalManager) {
		this.terminalManager = terminalManager;
	}

}
